import java.util.LinkedList;
import java.util.Queue;

public class MyQueue {
    static class ListNode{
        public int val;
        public ListNode next;
        ListNode(int val){
            this.val = val;
        }
    }
    public ListNode head ;
    public ListNode tail ;
    public int uesdSize = 0;
    boolean isEmpty(){
        if( head == null && uesdSize == 0){
            return true;
        }
        return false;
    }
    //  入队列
    void offer(int val){
        ListNode node = new ListNode(val);
        if(isEmpty()){
            head = node;
            head = tail;
        }else{
            tail.next = node;
            tail = tail.next;
            uesdSize++;
        }
    }
    //  出队列
    public int poll(){
        if(isEmpty()){
            return -1;
        }
        int ret = head.val;
        head = head.next;
        //更新队尾
        if(head == null){
            tail = head;
        }
        uesdSize--;
        return ret;
    }

    //瞄一眼
    public int peek() {
        if(isEmpty()){
            return -1;
        }
        return head.val;
    }

    public int getUesdSize(){
        return uesdSize;
    }
}
